Skip to content

Raise more informative ROBOT error#37

Merged
cthoyt merged 14 commits into
mainfrom
robot_error
Jul 6, 2025
Merged

Raise more informative ROBOT error#37
cthoyt merged 14 commits into
mainfrom
robot_error

Conversation

@bgyori

@bgyori bgyori commented May 3, 2025

Copy link
Copy Markdown
Contributor

I've often been confused by the error shown if Robot conversion fails since it doesn't show the actual output from Robot so the reason for the error is unclear:

CalledProcessError: Command '['java', '-jar', '/Users/ben/.data/robot/1.9.7/robot.jar', 'merge', '-i',
 '/Users/ben/.data/pyobo/raw/bao/bao_complete.owl', 'convert', '-o', 
'/Users/ben/.data/pyobo/raw/bao/bao_complete.obo']' returned non-zero exit status 1.

There are two challenges: subprocess.CalledProcessError doesn't surface the output by default and the output can be very long which if fully displayed would be disruptive. So this PR adds a custom RobotError class which is raised instead of subprocess.CalledProcessError and creates a nicer and easier-to-customize output:

RobotError: Command ['java', '-jar', '/Users/ben/.data/robot/1.9.7/robot.jar', 'merge', '-i', 
'/Users/ben/.data/pyobo/raw/bao/bao_complete.owl', 'convert', '-o', 
'/Users/ben/.data/pyobo/raw/bao/bao_complete.obo'] returned non-zero exit status 1.
Output: OBO STRUCTURE ERROR Ontology does not conform to OBO structure rules:
multiple name tags not allowed. in frame:Frame(null ontology( http://www.bioassayontology.org/
bao/bao_complete.owl)data-version( http://www.bioassayontology.org/bao/bao_complete.owl)
property_value( dc:date March20, 2025 xsd:string)property_value( dc:license 
https://creativecommons.org/licenses/by-sa/4.0/)remark( Contact: Stephan Schurer stephan 
dot schurer at med dot miami dot edu)remark( Created by: Caty Chung, Nicolette Ross...

by default showing up to 500 characters of the actual Robot error.

Fixes #10 though taking a different approach to the one suggested there.

@cthoyt cthoyt changed the title Raise more informative Robot error Raise more informative ROBOT error Jul 6, 2025
@cthoyt cthoyt merged commit ac99273 into main Jul 6, 2025
11 checks passed
@cthoyt cthoyt deleted the robot_error branch July 6, 2025 09:37
@cthoyt

cthoyt commented Jul 6, 2025

Copy link
Copy Markdown
Member

thanks!

@joeflack4

Copy link
Copy Markdown

@bgyori Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gracefully handle robot exceptions

3 participants